﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.IO;
using System.Data.OleDb;
using System.Data;
using TimeTableManagement.Entities;

namespace TimeTableManagement.Controllers
{
    public class FileController : Controller
    {
        //
        // GET: /File/
        String filename;
        public ActionResult Upload(string control, string action)
        {
            foreach (string inputTagName in Request.Files)
            {
                HttpPostedFileBase file = Request.Files[inputTagName];
                filename = file.FileName;          
                if (file.ContentLength > 0)
                {
                    string filePath = Path.Combine(HttpContext.Server.MapPath("../Uploads")
                        , Path.GetFileName(filename));                   
                    file.SaveAs(filePath);
                }    
            }
            return RedirectToAction(action, control, new { filename = filename });
        }
    }
}
